<!-- 首页 -->
<template>
	<view class="container">
		<TopNav title="数据统计" theme="white"></TopNav>
		<view class="main">
			<view class="card">
				<view class="text-gray f-s12 text-center">
					<text>{{detailData.start}} - {{detailData.end}}</text>
				</view>
				<view class="flex justify-evenly align-center m-t12">
					<view class="text-center">
						<view class="">
							<text class="text-bold f-s28">{{detailData.achievement || '-'}}</text>
						</view>
						<view class="m-t11">
							<text class="text-gray f-s12">本期业绩(元)</text>
						</view>
					</view>
					<view class="card-line"></view>
					<view class="text-center">
						<view class="">
							<text class="text-bold f-s28">{{detailData.income || '-'}}</text>
						</view>
						<view class="m-t11">
							<text class="text-gray f-s12">本期收入(元)</text>
						</view>
					</view>
				</view>
				<view class="flex justify-between"
					style="background-color: #F5F6F7;border-radius: 12rpx;padding: 20rpx 24rpx;margin-top: 26rpx;">
					<view class="flex flex-direction align-center">
						<text class="text-bold f-s16">{{detailData.item || '-'}}</text>
						<text class="text-gray f-s12 m-t10">项目收入</text>
					</view>
					<view class="flex flex-direction align-center">
						<text class="text-bold f-s16">{{detailData.fare || '-'}}</text>
						<text class="text-gray f-s12 m-t10">车费收入</text>
					</view>
					<view class="flex flex-direction align-center">
						<text class="text-bold f-s16">{{detailData.clock || '-'}}%</text>
						<text class="text-gray f-s12 m-t10">加时率</text>
					</view>
					<view class="flex flex-direction align-center">
						<text class="text-bold f-s16">{{detailData.duration || '-'}}</text>
						<text class="text-gray f-s12 m-t10">在线时长</text>
					</view>
				</view>
			</view>
			<view class="flex-1 overflow-hidden m-t12">
				<scroll-view class="full-height" scroll-y="true" @scrolltolower="handleScrollBottom">
					<view class="radius bg-white list-item" v-for="item in list" :key="item.id">
						<view class="flex align-center">
							<image src="/static/images/index/calendar.png" class="width-14 height-14" mode=""></image>
							<text class="f-w500 f-s14 m-l6">{{item.date}}</text>
						</view>
						<view class="m-t16 flex justify-around">
							<view class="flex flex-direction align-center">
								<text class="text-bold f-s16">{{item.achievement}}</text>
								<text class="f-s12 text-gray f-w400 m-t8">业绩(元)</text>
							</view>
							<view class="flex flex-direction align-center">
								<text class="text-bold f-s16">{{item.item}}</text>
								<text class="f-s12 text-gray f-w400 m-t8">分成(元)</text>
							</view>
							<view class="flex flex-direction align-center">
								<text class="text-bold f-s16">{{item.fare}}</text>
								<text class="f-s12 text-gray f-w400 m-t8">车费(元)</text>
							</view>
							<view class="flex flex-direction align-center">
								<text class="text-bold f-s16">{{item.order}}</text>
								<text class="f-s12 text-gray f-w400 m-t8">订单</text>
							</view>
							<view class="flex flex-direction align-center">
								<text class="text-bold f-s16">{{item.clock}}</text>
								<text class="f-s12 text-gray f-w400 m-t8">加时</text>
							</view>
						</view>
					</view>
					<view class="padding-tb-xs" v-if="total !== 0">
						<u-loadmore :status="loadmoreStatus" line @loadmore="handleScrollBottom" />
					</view>
					<Empty :show="total === 0" top="20rpx"></Empty>
				</scroll-view>
			</view>

		</view>
	</view>
</template>

<script>
	import mixins from "@/mixins";
	import Subsection from '@/components/subsection/index.vue'
	import Empty from '@/components/empty/index.vue'
	import {
		data,
		dataList
	} from "@/api/index/data"
	export default {
		name: "",
		mixins: [mixins],
		components: {
			Empty
		},
		data() {
			return {
				detailData: {},
				list: [],
				queryParams: {
					page: 1,
					limit: 10
				},
			}
		},
		onLoad() {
			this.getData()
		},
		methods: {
			getData() {
				this.getDetail()
				this.getList()
			},
			getList() {
				dataList(this.queryParams).then(res => {
					let {
						data: {
							list,
							count,
							total
						}
					} = res
					this.total = count || 0
					this.pageTotal = total || 0
					if (this.queryParams.page === this.pageTotal) this.loadmoreStatus = 'nomore'
					if (this.queryParams.page === 1) {
						this.list = list
					} else if (this.queryParams.page < this.pageTotal) {
						this.list = this.list.concat(list)
					}
				})
			},
			getDetail() {
				data().then(res => {
					let {
						data
					} = res
					this.detailData = data
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	@import '@/common/css/var.scss';

	.container {
		background: url('/static/images/index/statictics-bg.png') no-repeat fixed top center / 100% auto;

		.main {
			padding: 24rpx;
			padding-top: 36rpx;
			@include fixed-height;
			overflow: hidden;
			display: flex;
			flex-direction: column;

			.card {
				width: 100%;
				border-radius: 20rpx;
				background-color: #fff;
				padding: 20rpx 16rpx 16rpx 16rpx;
				margin-bottom: 20rpx;

				.card-line {
					width: 2rpx;
					height: 72rpx;
					background-color: #DDE0E6;
				}
			}

			.list-item {
				padding: 20rpx 16rpx 28rpx 16rpx;
				margin-bottom: 20rpx;
			}
		}
	}
</style>